import { useNavigate, useLocation } from "react-router"

const Testtwo = ({ msg }) => {
    let navigate = useNavigate();
    const location = useLocation();
    const clearState = () => {
        navigate(location.pathname, { state: null, replace: true })
    }
    return (
        <div className="mt-5 ml-5 p-5">
            {msg}
            <button className="btn btn-primary" onClick={clearState}>清除state</button>
        </div>
    )
}
export default Testtwo
